package cn.wolfcode.shop.controller;

import cn.wolfcode.shop.activemq.produce.OrderProduce;
import cn.wolfcode.shop.domain.UserLogin;
import cn.wolfcode.shop.service.IOrderInfoService;
import cn.wolfcode.shop.vo.JSONResult;
import cn.wolfcode.shop.vo.OrderVo;
import com.alibaba.fastjson.JSON;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("orders")
public class OrderController {

    @Reference
    private IOrderInfoService orderInfoService;
    @Autowired
    private OrderProduce orderProduce;
    /**
     * 生成订单
     * @return
     */
    @PostMapping
    public JSONResult createOrder(@RequestBody OrderVo orderVo, UserLogin userLogin){
        JSONResult jsonResult=new JSONResult();
        orderVo.setUserLogin(userLogin);
        orderProduce.publishOrderQueueMsg(JSON.toJSONString(orderVo));
        /*orderInfoService.createOrder(orderVo);*/
        return jsonResult;
    }
}
